﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using App.Utilities.Web.Handlers;
using System.Data;
using CRMBiz;
using Newtonsoft.Json;
using CRMWeb.Utilities.Context;
namespace CRMWeb.WebServices
{
    /// <summary>
    /// Summary description for ApplicationRecent
    /// </summary>
    public class ApplicationRecent : BaseHandler
    {
        public override void OnMethodInvoke(OnMethodInvokeArgs e)
        {
            context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            context.Response.Cache.SetExpires(DateTime.MinValue);
            context.Response.Cache.SetNoStore();

            //e.Cancel = true;

            SetResponseContentType(ResponseContentTypes.HTML);
        }

        public override void AfterMethodInvoke(object result)
        {
            base.AfterMethodInvoke(result);
        }
        
        #region "Private Methods"
        
        public void GetRecentRecord(int totallimit)
        {
            try
            {
                int OperatorID = Convert.ToInt32(CMSContext.CurrentUser.NodeID);
                DataSet ds = ApplicationRecentHandler.GetRecentRecord(totallimit, OperatorID);
                context.Response.Write(JsonConvert.SerializeObject(ds.Tables[0]));
            }
            catch (Exception ex)
            {
                ErrorHandler.saveErrorLog(ex,CMSContext.CurrentUser.MemberName);
            }
        }
        
        #endregion
    }
}